package cn.topkinson.dubbo.c.service.impl;

import cn.topkinson.api.HelloService;
import org.apache.dubbo.config.annotation.Service;

/**
 * @author 黄子濠
 * @date 2020/8/30 21:42
 */
@Service
public class HelloServiceImpl implements HelloService {
    @Override
    public String sayHello(String name, int timeToWait) {
        return "hello ["+name+"],I am dubbo C";
    }

    @Override
    public String methodA(String str) {
        return method("methodA");
    }
    @Override
    public String methodB(String str) {
        return method("methodB");
    }
    @Override
    public String methodC(String str) {
        return method("methodC");
    }

    private String method(String str){
        int sleepTime = (int)(Math.random() * 100);
        try {
            Thread.sleep(sleepTime);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(str+"===经过"+sleepTime+"ms睡眠===");
        return "ok";
    }
}
